package com.zhangfb95.crosschain.plugin.container.java.fabric2.infra.config.properties;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author zhangfubing
 * @since 2023/11/4
 */

@Data
@Accessors(chain = true)
@Component
@ConfigurationProperties("biz.service.cross-chain-server")
public class CrossChainServerProperties {

    /**
     * 访问方式, remote: 远程, local: 本地
     */
    private String accessType;
    /**
     * 远程访问时的信息
     */
    private RemoteInfo remoteInfo;
    /**
     * 本地访问时的信息
     */
    private List<LocalInfo> localInfos;

    @Data
    @Accessors(chain = true)
    public static class RemoteInfo {

        /**
         * 跨链服务url
         */
        private String url;
        /**
         * ssl类型, none: 不开启, rsa: rsa, gm: 国密
         */
        private String sslType;
        /**
         * ssl根ca
         */
        private String caCert;
        /**
         * ssl key
         */
        private String sslKey;
        /**
         * ssl cert
         */
        private String sslCert;
    }

    @Data
    @Accessors(chain = true)
    public static class LocalInfo {

        /**
         * 链路径
         */
        private String chainPath;
        /**
         * 私钥
         */
        private String privateKey;
        /**
         * 公钥
         */
        private String publicKey;
        /**
         * 属性map
         */
        private Map<String, String> propertyMap;
    }
}
